﻿@page "/About"
@using Markdig
@using Markdig.Syntax
@using Markdig.Syntax.Inlines
<PageTitle>关于</PageTitle>

<GridRow>
    <GridCol Md="6" Lg="6" Xl="5" Xxl="5"
             class="desktop-phone" style="overflow: auto;width:200px;">
        <Menu Theme="MenuTheme.Light"
              Mode="MenuMode.Inline" Class="menu-block">
            <MenuItemGroup Class="group-block">
                <TitleTemplate>
                    <div class="group-title">
                        网站介绍
                    </div>
                </TitleTemplate>
                <ChildContent>
                    <MenuItem RouterLink="/"
                              RouterMatch="NavLinkMatch.All">
                        主页
                    </MenuItem>
                    <MenuItem RouterLink="/About"
                              RouterMatch="NavLinkMatch.All">
                        关于
                    </MenuItem>
                </ChildContent>
            </MenuItemGroup>
        </Menu>
    </GridCol>
    <GridCol Xs="24" Sm="24" Md="18" Lg="18" Xl="19" Xxl="19"
             Style="padding: 20px;min-height: 100vh;">
        <MarkdownRenderer html="@Content"/>
        <BackTop Style="margin-bottom:60px">
            <div class="ant-back-top-inner">
                <Icon Type="arrow-up" Theme="outline"/>
            </div>
        </BackTop>
    </GridCol>
</GridRow>


@code
{
    private string Content { get; set; } = "";

    protected override async Task OnParametersSetAsync()
    {
        var info = new FileInfo($"wwwroot/Docs/about.md");
        if (!info.Exists) return;

        var pipeline = new MarkdownPipelineBuilder()
            .UseAdvancedExtensions()
            .UseBootstrap()
            .UseEmojiAndSmiley()
            .UseSmartyPants()
            .UseSoftlineBreakAsHardlineBreak()
            .Build();
        var content = await File.ReadAllTextAsync(info.FullName);

        var document = Markdown.Parse(content, pipeline);
        foreach (var node in document)
        {
            if (node is not ParagraphBlock { Inline: not null } paragraphBlock) continue;
            foreach (var inline in paragraphBlock.Inline)
            {
                if (inline is not LinkInline { IsImage: true } linkInline) continue;
                if (!linkInline.Url!.StartsWith("http"))
                    linkInline.Url = $"Docs/Image/{linkInline.Url}";
            }
        }

        Content = document.ToHtml();
    }
}

<style>

    h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
        font-size: x-large;
    }
    
    .footer{
        display: none;
    }

    @@media screen and (max-width: 768px) {
        .footer {
            display: block !important;
        }
    }
</style>